package com.zxw.hotel.config;


import com.zxw.hotel.common.JwtInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
//开启缓存
@EnableCaching
@EnableTransactionManagement
public class JwtConfig implements WebMvcConfigurer {
    @Value("${jwt.secret.key}")
    private String jwtsecret;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtInterceptor(jwtsecret))
                .addPathPatterns("/api/v1/**")
                .excludePathPatterns("/api/v1/admins/login/**")
                .excludePathPatterns("/api/v1/admins/logout/**")
                .excludePathPatterns("/api/v1/admins/captcha/**")
                .excludePathPatterns("/api/v1/uploads/**")
                .excludePathPatterns("/**");//非调用禁用此行
    }
}
